<?php

namespace App\Listeners;

use App\Events\UserRegistered;
use App\Models\PowerLog;
use App\Models\User;
use App\Models\Wallet;

class RaisePower
{

    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {

    }

    /**
     * Handle the event.
     *
     * @param  UserRegistered  $event
     * @return void
     */
    public function handle(UserRegistered $event)
    {
        $user_id = $event->user_id;

        Wallet::where('user_id', $user_id)->increment('computing_power', 100);
        PowerLog::add_log($user_id, 1, 100, 1);
    }
}
